package test;
import nme.display.FPS;
import nme.text.TextField;
import nme.display.Sprite;
import nme.text.TextFieldAutoSize;

/**
 * ...
 * @author liwei
 */

class TestBase extends Sprite
{
	private var _count:Int;
	private var _txt:TextField;
	public function new() 
	{
		super();
		_txt = new TextField();
		_txt.mouseEnabled = false;
		_txt.width = 500;
		_txt.multiline = true;
		_txt.wordWrap = true;
		_txt.autoSize = TextFieldAutoSize.LEFT;
		addChild(_txt);
		_txt.y = 20;
		_count = 0;
		var fps:FPS = new FPS(0,0);
		addChild(fps);
		
		
	}
	public function log(msg:String):Void {
		if (_count > 20) {
			_count = 0;
			_txt.text = "";
		}
		_txt.appendText(msg + "\n");
		_count++;
	}
	public function start():Void {
		
	}
	public function getobj(obj:Dynamic):String
	{
      if (obj==null)
      {
         return null;
      }
      if (Std.is(obj, String)) {
		  return cast (obj, String);
	  }
      var str:String="{";
      var iter:Iterator<String>=Reflect.fields(obj).iterator();
      for (i in iter)
      {
         str+=i+"="+Reflect.field(obj,i);
         if (iter.hasNext())
         {
            str+=",";
         }
      }
      str+="}";
      
      return str;
   }
	
}